<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    // 数组排序
    // 利用 数组的sort 封装一下
    // 如果 a > b 排后
    var arr = [3, 4, 1, 2, 6, 5, 10, 23, 22, 1];
    function sort(arr) {
      var newArr = arr.sort(function (a, b) {
        return a - b;
      });
      return newArr;
    }

    //  [1, 1, 2, 3, 4, 5, 6, 10, 22, 23]
    console.log(sort(arr));
  </script>
</body>

</html>